<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>


        // 找到数组中每个字母出现的次数["c", "a", "z", "a", "a"] 
        // 对象形式统计{c:1,a:3,z:1}


        var arr = ["c", "a", "z", "a", "a"]
        var obj = {};
        for(i = 0;i<=arr.length-1;i++){
            if(obj[arr[i]]){
                obj[arr[i]] = obj[arr[i]] + 1;
            }else{
                obj[arr[i]] = 1;
            }
        }
        

        console.log(obj);


    </script>



</body>

</html>